#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int,int>
const int N = 3010;
int T;
int n,m,L,V;
int p[N];
struct node
{
    int d,v,a;
} car[N];
vector<int> record[N];
bool vis[N];

bool cmp(vector<int> x,vector<int> y)
{
    return x.size()>y.size();
}

signed main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);

    int T;cin>>T;
    while(T--)
    {

        memset(vis,0,sizeof vis);
        int num = 0 ;
        scanf("%lld %lld %lld %lld",&n,&m,&L,&V);
        for(int i=1;i<=m;i++)
            record[i].clear();
        for(int i=1;i<=n;i++)
            scanf("%lld %lld %lld",&car[i].d,&car[i].v,&car[i].a);
        for(int i=1;i<=m;i++)
            scanf("%lld",&p[i]);
        sort(p+1,p+m+1);
        for(int i=1;i<=n;i++)
        {
            int d = car[i].d,v = car[i].v,a = car[i].a;
            if(a==0)
            {
                if(v > V)
                {
                    int t = lower_bound(p+1,p+m+1,d)-p;
                    if(t<=m)
                    {
                        for(int j=t;j<=m;j++)
                            record[j].push_back(i);
                        num++;
                    }
                }
            }
            else if(a < 0)
            {
                a = abs(a);
                if(v > V)
                {
                     float x_v = 1.0 * (v*v-V*V) /(2.0*a);
                     int s = lower_bound(p+1,p+m+1,d)-p , t = lower_bound(p+1,p+m+1,d+x_v)-p ;
                     t--;
                     if(s<=t)
                     {
                         for(int j=s;j<=t;j++)
                           record[j].push_back(i);
                         num++;
                     }
                }
            }else // a > 0
            {
                if(v > V)
                {
                    int t = lower_bound(p+1,p+m+1,d)-p;
                    if(t<=m)
                    {
                        for(int j=t;j<=m;j++)
                            record[j].push_back(i);
                        num++;
                    }
                }else if(v==V)
                {
                    int t = upper_bound(p+1,p+m+1,d)-p;
                    if(t<=m)
                    {
                        for(int j=t;j<=m;j++)
                            record[j].push_back(i);
                        num++;
                    }
                }else
                {
                    float dis = sqrt((1.0*V*V-v*v)/(2.0*a)) ; // printf("%lld\n",dis);
                    int t = upper_bound(p+1,p+m+1,d+dis)-p;
                    if(t<=m)
                    {
                        for(int j=t;j<=m;j++)
                            record[j].push_back(i);
                        num++;
                    }
                }

            }
        }
        /*
        for(int i=1;i<=m;i++)
        {
            for(int j=0;j<record[i].size();j++)
                printf("%lld ",record[i][j]);
            puts("");
        }
        */
        sort(record+1,record+m+1,cmp);
        int need = 0;
        for(int i=1;i<=m;i++)
        {
            for(int j=0;j<record[i].size();j++)
            {
                if(!vis[record[i][j]])
                {
                    need++;
                    for(int t=j;t<record[i].size();t++)
                    {
                        vis[record[i][j]]=true;
                    }
                    break;
                }

            }
        }
        printf("%lld %lld\n",num,need);
    }
    return 0;
}
